using System;
using System.Drawing;
using System.Windows.Forms;


namespace Agron.UI.SmartClient
{
    internal class DataGridViewUtils
    {
        /// <summary>
        /// Draws the specified <see cref="Bitmap"/> in a cell within a <see cref="DataGridView"/>.
        /// </summary>
        /// <param name="bitmap">The <see cref="Bitmap"/> to draw.</param>
        /// <param name="e">The <see cref="DataGridViewCellPaintingEventArgs"/> instance containing the event data.</param>
        public static void DrawBitmapInCell(Bitmap bitmap, DataGridViewCellPaintingEventArgs e)
        {
            e.Graphics.DrawImage(
                /*bitmap*/ bitmap,
                /*x*/ (e.CellBounds.Left + ((e.CellBounds.Width - bitmap.Width) / 2)),
                /*y*/ (e.CellBounds.Top + ((e.CellBounds.Height - bitmap.Height) / 2)),
                /*width*/ bitmap.Width,
                /*height*/ bitmap.Height);
        }
    }
}
